<?php
namespace frontend\models\course;

use Yii;
use yii\db\ActiveRecord;
class CourseQues extends ActiveRecord{

	/**
	 * @inheritdoc
	 */
	public static function tableName()
	{
		return "edu_question";
	}
	/*课程里面的问答*/
	public function CourseQues($course_id){
		$model = $this
			->find()
			->select(["*,qs.ques_id,GROUP_CONCAT(gs.queslabel_name SEPARATOR ' / ') AS queslabel_name"])
			->from("edu_question as qs")
			->leftjoin("edu_user","qs.user_id=edu_user.user_id")
			->leftjoin("edu_question_label as ab","qs.ques_id=ab.ques_id")
			->leftjoin("edu_queslabel as gs","ab.queslabel_id=gs.queslabel_id")
			->leftjoin("edu_course","qs.course_id=edu_course.course_id")
			->where("qs.ques_type=1 and qs.course_id=$course_id")
			->groupby("qs.ques_id")
			->orderby("qs.ques_addtime desc")
			->asArray()
			->all();
		return $model;
	}
}
?>